package collection.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Random;

public class StreamApiDemo2 {
    public static void main(String[] args) {
        Random ran = new Random();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(ran.nextInt(100));
        }
        System.out.println(list);

        Optional<Integer> value = list.stream().min((e1,e2)->e1-e2);
        System.out.println(value.get());
        int max = list.stream().max((e1,e2)->e1-e2).get();
        System.out.println(max);

        boolean ou = list.stream().anyMatch((e1)->e1%2==0);
        System.out.println(ou);

        boolean ou1 = list.stream().allMatch(e1 ->e1%2!=0);
        System.out.println(ou1);

        boolean ou2 = list.stream().noneMatch(e1->e1%2==0);
        System.out.println(ou2);

        int num = list.stream().reduce((e1,e2)->e1+e2).get();
        System.out.println(num);

    }
}
